<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<%@taglib prefix="sx" uri="/struts-dojo-tags"%>

<link rel="stylesheet" type="text/css" href="js/yui/assets/skins/sam/paginator.css" />
<link rel="stylesheet" type="text/css" href="js/yui/assets/skins/sam/datatable.css" />
<link rel="stylesheet" type="text/css" href="js/yui/assets/skins/sam/container.css" />
<link rel="stylesheet" type="text/css" href="js/yui/assets/skins/sam/button.css" />
<link rel="stylesheet" type="text/css" href="js/yui/assets/skins/sam/calendar.css" />

<style type="text/css">
<!--
    .row-top-line{
        border-top: 1px solid #000000;
    }
    .require{
    	font-color: red;
    }
-->
</style>

<script type="text/javascript" src="js/yui/yuiloader/yuiloader-min.js"></script>
<script type="text/javascript" src="js/yui/yahoo-dom-event/yahoo-dom-event.js"></script>
<script type="text/javascript" src="js/yui/connection/connection-min.js"></script>
<script type="text/javascript" src="js/yui/json/json-min.js"></script>
<script type="text/javascript" src="js/yui/element/element-min.js"></script>
<script type="text/javascript" src="js/yui/paginator/paginator-min.js"></script>
<script type="text/javascript" src="js/yui/datasource/datasource-min.js"></script>
<script type="text/javascript" src="js/yui/datatable/datatable-min.js"></script>
<script type="text/javascript" src="js/yui/calendar/calendar-min.js"></script>
<script type="text/javascript" src="js/yui/container/container-min.js"></script>
<script type="text/javascript" src="js/yui/button/button-min.js"></script>
<script type="text/javascript" src="js/yui/event/event-min.js"></script>

<script type="text/javascript">

	var pnlLoading = new YAHOO.widget.Panel("pnlLoading",
	        {   width:"350px", height:"135px",
	            draggable: true,
	            fixedcenter: true,
	            modal: true,
	            context: ['anchorElement','bl','tr'],
	            close: true,
	            visible: false });
	pnlLoading.render(document.body);
	pnlLoading.hide();

	var pnlConfirm = new YAHOO.widget.Panel("pnlConfirm",
	        {   width:"350px", height:"120px",
	        draggable: true,
	        fixedcenter: true,
	        modal: true,
	        context: ['anchorElement','bl','tr'],
	        close: true,
	        visible: false });
	pnlConfirm.render(document.body);
	pnlConfirm.hide();
    
    var pnlDialog = new YAHOO.widget.Panel("pnlDialog",
                {   width:"350px", height:"220px",
                    draggable: true,
                    fixedcenter: true,
                    modal: true,
                    context: ['anchorElement','bl','tr'],
                    close: true,
                    visible: false });
    pnlDialog.render(document.body);
    if("<s:property value="#session['S_SHIFT_LOGIN_DLG']"/>" == "N"){
		pnlDialog.hide();
    } else{
    	pnlDialog.show();
    }
	
    var btnCancel = new YAHOO.widget.Button("btnCancel");
    btnCancel.on("click", function(e) {
    	pnlDialog.hide();
    	//window.location.href = "${pageContext.request.contextPath}/home.action";
    }, this, true);
    
    var btnLogin = new YAHOO.widget.Button("btnLogin");
    btnLogin.on("click", function(e) {
        var callback = {
            success : function(o) {
                var obj;
                try{
                    var jsonData = YAHOO.lang.JSON.parse(o.responseText);
                    obj = eval("("+ jsonData.object +")");
                    if(obj.status == 'Success'){
                    	pnlLoading.show();
                    	//alert(obj.shiftNo);
                    	if("<s:property value="#session['S_MENU_TYPE']"/>" == "RESERV"){
                    		window.location.href = "${pageContext.request.contextPath}/reserveOverview_execute.action";
                    	} else{
                    		window.location.href = "${pageContext.request.contextPath}/shiftControl_execute.action";
                    	}
                    } else if(obj.status == 'Confirm'){
                    	pnlDialog.hide();
                    	pnlConfirm.show();
                    } else{
                    	pnlDialog.hide();
                    	document.getElementById("errorText").innerHTML = obj.errDesc;
                    }
                } catch(x){
                	pnlDialog.hide();
            	}
            },
            failure: function(o){ pnlDialog.hide(); }
        };
        var DOM = YAHOO.util.Dom;
        var form = DOM.get("frmSelectTask");
        YAHOO.util.Connect.setForm(form);
        var conn = YAHOO.util.Connect.asyncRequest("POST", "${pageContext.request.contextPath}/firstPage_login.action", callback);
    }, this, true);

    var btnOpenShift = new YAHOO.widget.Button("btnOpenShift");
    btnOpenShift.on("click", function(e) {
    	pnlConfirm.hide();
    	pnlLoading.show();
    	window.location.href = "${pageContext.request.contextPath}/shiftControl_openShift.action";
    }, this, true);
	
    var btnCancelOpen = new YAHOO.widget.Button("btnCancelOpen");
    btnCancelOpen.on("click", function(e) {
    	window.location.href = "${pageContext.request.contextPath}/home.action";
    }, this, true);
    
</script>

<div id="pnlLoading" style="visibility: hidden; background-color: #ffffff;">
    <div class="hd">Please wait ...</div>
    <div class="bd" align="center">
    	<br>
        <img src="${pageContext.request.contextPath}/images/loading.gif">
    </div>
    <div id="statusDiv" class="ft">&nbsp;</div>
</div>

<div id="pnlConfirm" style="visibility: hidden; background-color: #ffffff;">
    <div class="hd">Confirm to Open Shift ...</div>
    <div class="bd" align="center">
    	<br>
		<input type="button" id="btnOpenShift" value=" Open Shift ">
        &nbsp; &nbsp; &nbsp;
		<input type="button" id="btnCancelOpen" value=" Cancel ">
    </div>
    <div id="statusDiv" class="ft">&nbsp;</div>
</div>

<div id="pnlDialog" style="visibility: hidden; background-color: #ffffff;">
    <div class="hd" align="left">Login to do shift control ...</div>
    <div class="bd" style="overflow:auto">
        <table width="300" cellspacing="0" align="center">
        <form id="frmSelectTask" action="#">
        <tr>
        	<td width="15"></td>
            <td height="35px" width="270" style="background-color: #DDDDDD" align="center">
            	Username : &nbsp; <s:property value="#session.SUserLogin.userName"/>
            </td>
        	<td width="15"></td>
        </tr>
        <tr>
        	<td width="15"></td>
            <td height="35px" width="270" style="background-color: #DDDDDD" align="center">
            	Password : ####
            </td>
        	<td width="15"></td>
        </tr>
        <tr>
        	<td width="15"></td>
            <td height="35px" width="270" style="background-color: #DDDDDD" align="center">
            	Counter : &nbsp; <s:property value="#session.SCounter.counterName"/>
            </td>
        	<td width="15"></td>
        </tr>
        <tr>
            <td colspan="3" align="center" height="45px">
                <input type="button" id="btnLogin" value=" Login ">
                &nbsp; &nbsp; &nbsp;
                <input type="button" id="btnCancel" value=" Cancel ">
            </td>
        </tr>
        </form>
        </table>
    </div>
    <div id="statusDiv" class="ft">&nbsp;</div>
</div>
